/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jsf;

import bean.AccountBean;
import ejb.Account;
import ejb.Customer;

/**
 *
 * @author longdm0708l
 */

public class LoginController {

    /** Creates a new instance of LoginController */
    public LoginController() {
    }

    String username;
    String password;
    String errorMes;
    private Account currentAccount;
    private Customer currentCustomer;

    public Account getCurrentAccount() {
        return currentAccount;
    }

    public Customer getCurrentCustomer() {
        return currentCustomer;
    }



    public String getErrorMes() {
        return errorMes;
    }

    public void setErrorMes(String errorMes) {
        this.errorMes = errorMes;
    }


    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String newCustomer()
    {
        currentAccount = new Account();
        currentCustomer = new Customer();
        return "newCustomer";
    }

    public String checkLogin()
    {
        AccountBean ab = new AccountBean();
        if (ab.checkLogin(username, password)==1){
            if("admin".compareToIgnoreCase(username) == 0){
                return "adminUser";
            }else{
                return "_customerUser";
            }
        }else{
            errorMes = "Login failed...";
            return "";
        }
    }


}
